Skip to content

[AutoBuild] Replaced platform triplet string comparison with platform comparison in rebuild_jll_package#1363

Merged
giordano merged 4 commits intoJuliaPackaging:masterfrom
stemann:feature/rebuild_jll_package_fix
Feb 9, 2025
Merged

[AutoBuild] Replaced platform triplet string comparison with platform comparison in rebuild_jll_package#1363
giordano merged 4 commits intoJuliaPackaging:masterfrom
stemann:feature/rebuild_jll_package_fix

Conversation

@stemann
Copy link
Contributor

@stemann stemann commented Feb 8, 2025

Should remedy issues seen with registration of ONNXRuntime_CUDA (using the cuda_platform platform tag, e.g., cuda_platform="jetson") in JuliaPackaging/Yggdrasil#10426, and investigated in JuliaPackaging/Yggdrasil#10476 .

Copy link
Member

@giordano giordano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked at the code very closely yet, but at a high level this looks very promising, thanks for doing this.

Might be an idea to look into a test or two…

Yes, the registration pipeline is largely untested here, because it's also complicated to reproduce end-to-end without a mock registry and such. However this is a small self-contained function which should be easy to unit test, so please do go ahead and add tests!

src/AutoBuild.jl Outdated
end
try
tarball_filename_platform = parse(Platform, tarball_filename_match[:platform_triplet])
return tarball_filename_platform == platform
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I'm not 100% sure is whether this comparison is fine. Platform equality is finicky, I usually prefer using platform_match, but probably in this case we really want to check exact equality specifically, so this may be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points - both of them. I’ll check up on platform_match.

Copy link
Member

@giordano giordano Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

julia> using Base.BinaryPlatforms

julia> p1 = Platform("x86_64", "linux"; tag1="foo", tag3="blah")
Linux x86_64 {libc=glibc, tag1=foo, tag3=blah}

julia> p2 = Platform("x86_64", "linux"; tag2="bar", tag4="glah")
Linux x86_64 {libc=glibc, tag2=bar, tag4=glah}

julia> p1 == p2
false

julia> platforms_match(p1, p2)
true

julia> p3 = Platform("x86_64", "linux"; tag3="blah", tag1="foo")
Linux x86_64 {libc=glibc, tag1=foo, tag3=blah}

julia> p4 = Platform("x86_64", "linux"; tag4="glah", tag2="bar")
Linux x86_64 {libc=glibc, tag2=bar, tag4=glah}

julia> platforms_match(p1, p3)
true

julia> p1 == p3
true

julia> p2 == p4
true

Probably equality is better than platform_match here, but make sure with appropriate tests that it works correctly also in complex cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added some tests.

I would argue that the functionality of the Platform constructor should not be tested here (p1 vs p3, and p2 vs p4), but the difference between Platform equality and platforms_match should, e.g. where platforms_match is true and equality is false,

julia> p5 = Platform("x86_64", "linux")
Linux x86_64 {libc=glibc}

julia> p6 = Platform("x86_64", "linux"; cxxstring_abi="cxx11")
Linux x86_64 {cxxstring_abi=cxx11, libc=glibc}

julia> platforms_match(p5, p6)
true

julia> p5 == p6
false

@stemann
Copy link
Contributor Author

stemann commented Feb 8, 2025

It should be noted that I did not get concrete evidence that this is indeed the root cause for the issues in JuliaPackaging/Yggdrasil#10426 etc., but it seems like a (very) likely cause. The issue with reproducation was primarily that triplet(platform) put cuda_platform before cuda - thus matching the tarballs:

With some quasi-empty tarballs in "./foo":

platforms = expand_cxxstring_abis([
    Platform("aarch64", "linux"; cuda="10.2", cuda_platform="jetson"),
    Platform("x86_64", "linux"; cuda="11.3"),
    Platform("x86_64", "windows"; cuda="11.3")
]; skip=!Sys.islinux)
# 5-element Vector{Platform}:
#  Linux aarch64 {cuda=10.2, cuda_platform=jetson, cxxstring_abi=cxx03, libc=glibc}
#  Linux aarch64 {cuda=10.2, cuda_platform=jetson, cxxstring_abi=cxx11, libc=glibc}
#  Linux x86_64 {cuda=11.3, cxxstring_abi=cxx03, libc=glibc}
#  Linux x86_64 {cuda=11.3, cxxstring_abi=cxx11, libc=glibc}
#  Windows x86_64 {cuda=11.3}

readdir(joinpath(pwd(), "foo"))
# ONNXRuntime_CUDA.v1.10.0.aarch64-linux-gnu-cxx03-cuda_platform+jetson-cuda+10.2.tar.gz
# ONNXRuntime_CUDA.v1.10.0.aarch64-linux-gnu-cxx11-cuda_platform+jetson-cuda+10.2.tar.gz
# ONNXRuntime_CUDA.v1.10.0.x86_64-linux-gnu-cxx03-cuda+11.3.tar.gz
# ONNXRuntime_CUDA.v1.10.0.x86_64-linux-gnu-cxx11-cuda+11.3.tar.gz
# ONNXRuntime_CUDA.v1.10.0.x86_64-w64-mingw32-cuda+11.3.tar.gz

triplet(first(platforms))
# "aarch64-linux-gnu-cxx03-cuda_platform+jetson-cuda+10.2"

BinaryBuilder.rebuild_jll_package("foo", v"0.1.0", [], platforms, [], [], joinpath(pwd(), "foo"), "foo"; verbose=true)
# Runs past finding platform for each file in "./foo"

I have also not discovered why the triplets sometimes had the cuda and cuda_platform tags in another order. ... perhaps an issue in Base.BinaryPlatforms...(?)

@giordano
Copy link
Member

giordano commented Feb 9, 2025

Is this ready?

I have also not discovered why the triplets sometimes had the cuda and cuda_platform tags in another order.

Dicts are not sorted, so that's totally expected.

@stemann
Copy link
Contributor Author

stemann commented Feb 9, 2025

OK.

Yes, I think it is ready.

@giordano giordano merged commit 4538e89 into JuliaPackaging:master Feb 9, 2025
9 checks passed
@stemann stemann deleted the feature/rebuild_jll_package_fix branch February 10, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants